/*
 *  Copyright 2011 yura.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */

package org.opu.vcforms.dtseditor;

import java.util.Properties;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.opu.vcforms.vcapi.VcApi;

/**
 * Hello world!
 *
 */
public class App {
    public static void main( String[] args ) {
        Properties prop = new Properties();
        prop.setProperty("jdbc.url", System.getProperty("url", "jdbc:postgresql://localhost:5432/dekanat"));
        prop.setProperty("jdbc.username", System.getProperty("user", "postgres"));
        prop.setProperty("jdbc.password", System.getProperty("pswd", "1"));
        prop.setProperty("hibernate.show_sql", "true");

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex) {
            Util.niceEx(ex, "DTSeditor", "Can't set system LookAndFeel\n");
        }

        VcApi api;
        Window w;
        try {
            api = VcApi.newVcApi(prop);
            w = new Window(api);
        } catch (RuntimeException e) {
            NewJDialog newJDialog = new NewJDialog(null, true);
            newJDialog.setLocationRelativeTo(null);
            e.printStackTrace();
            while (true) {
                try {
                    newJDialog.setVisible(true);
                    api = VcApi.newVcApi(newJDialog.prop);
                    w = new Window(api);
                    break;
                } catch (Exception e2) {
                    e2.printStackTrace();
                    Util.niceEx(e2, "DTSeditor");
                }
            }
        }

        w.setVisible(true);
        
    }
}
